﻿<Window x:Class="SqlExecuter.Client.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        xmlns:model="clr-namespace:SqlExecuter.Client.Model"
        Title="SQL Script Executer - Tushar Agarwal" Height="550" Width="800" 
        Loaded="Window_Loaded" Icon="/SqlExecuter.Client;component/AppIcon.ico">
    <Window.Resources>
        <HierarchicalDataTemplate DataType="{x:Type model:FsDirectory}" ItemsSource="{Binding Path=DirectoriesAndFiles}">
            <TextBlock Text="{Binding Name}" />
        </HierarchicalDataTemplate>
        <DataTemplate DataType="{x:Type model:FsFile}">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsSelected}" Margin="0,0,10,0" />
                <TextBlock Text="{Binding Path=Name}"                           >
                    <TextBlock.Style>
                        <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                    <Setter Property="Background" Value="PowderBlue" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    <DockPanel HorizontalAlignment="Stretch">

        <StackPanel DockPanel.Dock="Bottom">
            <StatusBar>
                <StatusBarItem>Ready</StatusBarItem>
                <StatusBarItem HorizontalAlignment="Right">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="0,0,10,0">Selected Files:</TextBlock>
                        <TextBlock Text="{Binding SelectedItemsCount, Mode=OneWay}" />
                    </StackPanel>

                </StatusBarItem>
            </StatusBar>

        </StackPanel>
        <Grid DockPanel.Dock="Top">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="20" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            
            <DockPanel Grid.Row="1" LastChildFill="True" >
                <StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
                    <Button Content="Browse..." Click="Browse_Click" />
                    <Button Content="Populate" Command="{Binding Populate}"/>
                    <Button Content="Display Files Content" Command="{Binding DisplayContent}" />
                    <Button Content="Copy to Clipboard" Command="{Binding Copy}" />
                </StackPanel>
                <Label Margin="0,0,15,0" DockPanel.Dock="Left">Root Directory:</Label>
                <ComboBox  ItemsSource="{Binding RecentPaths}"  IsEditable="True" Text="{Binding RootDirectoryPath}"/>
                
            </DockPanel>

            <Grid Grid.Row="3" Margin="5,0,5,0"  >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="300" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="25" />
                </Grid.RowDefinitions>
                <Label >Select the list of files to execute:</Label>
                <TreeView Grid.Row="1"  Name="treeView1"   VerticalAlignment="Stretch"
                      ItemsSource="{Binding Path=RootDirectory.DirectoriesAndFiles}" SelectedItemChanged="treeView1_SelectedItemChanged">
                </TreeView>
                <Button Grid.Row="2" Content="Select All" Command="{Binding SelectAllFiles}" Width="100" HorizontalAlignment="Center"/>
                <Label Grid.Column="1"   Margin="10,0,0,0" >The Combined Content of the selected files:</Label>
                <ScrollViewer Grid.Row="1" Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Auto" >
                    <TextBox   Margin="10,0,0,0" Text="{Binding FilesContent}"  IsReadOnly="True" TextWrapping="Wrap" />
                </ScrollViewer>

            </Grid>

        </Grid>
    </DockPanel>

</Window>
